package com.last.controller;

import com.api.search.SearchApi;
import com.last.entity.City;
import com.last.entity.CityDTO;
import com.last.entity.PageResult;
import com.last.entity.Result;
import com.last.service.ICityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/city")
public class CityController {
    @Autowired
    private ICityService iCityService;
    @Autowired
    private SearchApi searchApi;

    @RequestMapping("/search")
    public PageResult search(@RequestBody Map<String,String> map){
        PageResult pageResult = searchApi.searchByWhere(map);
        return pageResult;
    }

    @RequestMapping("/searchCity")
    public List<CityDTO> getCityFromRedis(){
        List<CityDTO> cityFromRedis = iCityService.getCityFromRedis();
        return cityFromRedis;
    }

}
